package com.project_doctor.listener;



import com.project_doctor.util.SmsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
@Slf4j
public class SMSListener {
    @Autowired
    SmsUtil smsUtil;

    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 监听邮件队列，发送邮件
     * 对指定的队列进行监听，并且将数据注入给方法的形参
     */
    @RabbitListener(queues = "sms.queue")
    public void sendEmail(HashMap<String, String> smsData) {
        log.info("监听到电话短信队列，开始发送，数据：{}", smsData);
        String code = smsData.get("code");
        String phone = smsData.get("phone");
//        smsUtil.sendSms(phone, code);
    }
}